package com.atguigu.gulimall.ware.service;

import com.atguigu.common.to.mq.StockLockedTo;
import com.atguigu.common.to.order.OrderTO;
import com.atguigu.common.to.ware.WareSkuLockTO;
import com.atguigu.gulimall.ware.vo.SkuHasStockVo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.gulimall.ware.entity.WareSkuEntity;

import java.util.List;
import java.util.Map;

/**
 * 商品库存
 *
 * @author lianming
 * @email sun_moon2022@sina.com
 * @date 2022-05-24 10:13:34
 */
public interface WareSkuService extends IService<WareSkuEntity> {

    PageUtils queryPage(Map<String, Object> params);

    void addStock(Long skuId, Long wareId, Integer skuNum);


    List<SkuHasStockVo> getSkusHasStock(List<Long> skuIds);

    /**
     * 库存锁定
     * sql执行增加锁定
     */
    Boolean orderLockStock(WareSkuLockTO lockTO);

    /**
     * 库存解锁
     * 供监听死信队列方法调用
     */
    void unLockStock(StockLockedTo locked) throws Exception;

    /**
     * 库存解锁
     * 订单解锁触发
     */
    void unLockStock(OrderTO order);
}

